<?xml version="1.0" encoding="UTF-8"?>
<!--
  Created by IntelliJ IDEA.
  User: azim
  Date: 5/12/13
  Time: 1:12 PM
-->
<!DOCTYPE html
        PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">

<ui:composition template="templates/template.xhtml">

    <ui:define name="title">User Registration Page</ui:define>

    <ui:define name="cbody">

        <h2>Please fill up the following form for registration : </h2>
        <br/>
        <h:form id="create_user">

            <h:panelGrid columns="3" cellspacing="10" style="margin-bottom: 5px">

                <p:outputLabel styleClass="label" for="username" value="Username : "/>
                <p:inputText id="username"
                             value="#{loginController.user.username}"
                             required="true"
                             requiredMessage="Error : Username is required"/>
                <p:message for="username" styleClass="error"/>

                <p:outputLabel styleClass="label" for="password" value="Password : "/>
                <p:password id="password"
                            value="#{loginController.user.password}"
                            required="true"
                            requiredMessage="Error : Password is required"/>
                <p:message for="password" styleClass="error"/>

                <p:outputLabel styleClass="label" for="confirmPassword" value="Confirm Password : "/>
                <p:password id="confirmPassword"
                            value="#{loginController.user.confirmPassword}"
                            required="true"
                            requiredMessage="Error : Confirm Password is required"/>
                <p:message for="confirmPassword" styleClass="error"/>

                <p:outputLabel styleClass="label" for="email" value="Email : "/>
                <p:inputText id="email"
                             value="#{loginController.user.email}"
                             required="true"
                             requiredMessage="Error : Email is required"
                             validatorMessage="Invalid email format">

                    <f:validateRegex
                            pattern="^[_A-Za-z0-9-\+]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9]+)*(\.[A-Za-z]{2,})$"/>

                </p:inputText>
                <p:message for="email" styleClass="error"/>


            </h:panelGrid>

            <p:commandButton value="SignUp" action="#{loginController.signUp}" ajax="false"/>

        </h:form>

        <p:messages globalOnly="true"/>

    </ui:define>

</ui:composition>

</html>